<template>
    <el-dialog  title="打开表数据" :visible="true" @close="cancel()" destroy-on-close width="1000px"> 
         <el-table 
          :data="tableData" 
          stripe 
          size="small" 
          :highlight-current-row ="highlight"
          show-overflow-tooltip
          v-loading="dialogLoading"
          :lock-scroll="true"
          height="450"
        >
          <el-table-column  v-for="(item,index) in fieldData" :key="index" :prop="item.fmt" :label="item.name"
             show-overflow-tooltip
          >
          </el-table-column>
        </el-table>
    </el-dialog>
</template>

<script>
import { getDataList} from '@/api/dataManagement/dataFields'
export default {
     props: {
        id: String,
        tableName: String
    },
    data() {
        return {
            fieldData: [],
            tableData: [],
            dataTableList: {},
            dialogLoading: false
        }
    },
    created() {
        this.dialogLoading = true
         const data = {
                id: this.id,
                tableName: this.tableName
            }
            getDataList(data).then((res) => {
            if(res.code === 0) {
                this.dataTableList = res.data
                this.fieldData = res.data.columns
                this.tableData = res.data.rowMaps
                this.dialogLoading = false
            }
        })
    },
    methods: {
        cancel() {
            this.$emit('closeDataTable')
        },
    }
}
</script>
